<?php

/*
Add Trivia Games (admin_add_trivia_game.pro.php)
*/

$page_title = "Add Trivia Game";
$rank_check = 7;
include "../global.inc.php";

$check = fetch("SELECT * FROM trivia_games WHERE game = '$game' AND gamename = '$add_game_name'");

if ($check[id])
{
	die(header(error("admin_add_trivia_game.php?game=$game","There is already a game called $add_game_name.")));
}

if ((!$add_game_name) OR (!$add_game_desc) OR (!$game_prize) OR (!$game_price))
{
	die(header(error("admin_add_trivia_game.php?game=$game","Please fill out every field.")));
}

if (($game_price < 0) OR ($game_prize < 0))
{
	die(header(error("admin_add_trivia_game.php?game=$game","Price and prize per question must be greater than zero.")));
}

$add_game_name = strip_tags($add_game_name);
$add_game_desc = strip_tags($add_game_desc,"<font><b><i><u>");

mysql_query("INSERT INTO trivia_games VALUES ('','$add_game_name','$add_game_desc','$game_prize','$game_price','$game')");

$insert_id = mysql_insert_id();

header(error("admin_add_trivia_question.php?game=$game&trivia=$insert_id","The game \"$add_game_name\" was successfully created. Now you should add questions."));

?>
